local MagickeyCard = class("MagickeyCard")

function MagickeyCard:ctor()
end

function MagickeyCard:start()
    self._panelTouch:SetCallback(handler(self, self._onTouchClick))
end

function MagickeyCard:setCallback(callback)
    self._callback = callback
end

function MagickeyCard:updateUI(data, selectedId)
    self._data = data
    local config = data:getConfig()
    self._textName.text = config.name
    self._check.isOn = self._data:getId() == selectedId
    self._imageMagickey.sprite = G_ResourceManager:loadSprite("MagickeyAltas", config.res)
end

function MagickeyCard:_onTouchClick(state)
    if state == 3 then
        if self._callback and self._data then
            self._callback(self._data:getId())
        end
    end
end

return MagickeyCard
